package com.example.test.controller;

import com.example.test.entity.PageBean;
import com.example.test.entity.User;
import com.example.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping(value = "/user",method = RequestMethod.POST)
    public List<User> findList(){
        return userService.findList();
    }


    /**
     * 商品分页功能(集成mybatis的分页插件pageHelper实现)
     *
     * @param currentPage    :当前页数
     * @param pageSize        :每页显示的总记录数
     * @return
     */
    @RequestMapping(value = "/itemsPage",method = RequestMethod.POST)
    public PageBean<User> itemsPage(int currentPage, int pageSize){
        return userService.findItemByPage(currentPage, pageSize);
    }
}
